from rest_framework.generics import ListAPIView, ListCreateAPIView, RetrieveUpdateDestroyAPIView

from goods.models import GoodsSpecification
from meiduo_admin.serializers.specs import  GoodsSpecSerializer
from meiduo_admin.utils import PageNum



class GoodsSpecsModelViewSet(ListCreateAPIView):
    serializer_class = GoodsSpecSerializer
    pagination_class = PageNum
    queryset = GoodsSpecification.objects.all()



class GoodsSpecsViewSet(RetrieveUpdateDestroyAPIView):
    serializer_class = GoodsSpecSerializer
    pagination_class = PageNum
    def get_queryset(self):
        pk = int(self.kwargs['pk'])
        return GoodsSpecification.objects.filter(id=pk)
